package com.xjoyt.pay.controllers;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.xjoyt.pay.dto.CallbackResult;
import com.xjoyt.pay.dto.MerchantChannelRegister;
import com.xjoyt.pay.dto.OrderUrlResult;
import com.xjoyt.pay.dto.params.CallbackParam;
import com.xjoyt.pay.dto.params.MerchantRateRegister;
import com.xjoyt.pay.dto.params.OrderAdapterParam;

/**
 * demo适配器
 * 
 * @author Administrator
 *
 */
@RestController
public class DemoController {

	/**
	 * 商户进件
	 * 
	 * @param param
	 * @return
	 */
	@PostMapping("register")
	public MerchantChannelRegister register(@RequestBody MerchantRateRegister param) {
		MerchantChannelRegister result = new MerchantChannelRegister();
		result.no = "上游商户号";
		result.key = "上游商户密码";
		return result;
	}

	/**
	 * 微信扫码
	 * 
	 * @param param
	 * @return
	 */
	@PostMapping("wechatScan")
	public OrderUrlResult wechatScan(@RequestBody OrderAdapterParam param) {
		OrderUrlResult result = new OrderUrlResult();
		result.success = true;
		result.url = "微信扫码URL";
		return result;
	}

	/**
	 * 回调适配器处理
	 * 
	 * @param param
	 * @return
	 */
	@PostMapping("callback")
	public CallbackResult callback(@RequestBody CallbackParam param) {
		CallbackResult result = new CallbackResult();
		result.success = true;
		// 上游响应
		result.callbackResponse = "SUCCESS";
		return result;
	}

}
